package com.movitech.mobile.cz.base.bizconfig.controller;


import com.movitech.mobile.cz.base.bizconfig.entity.ext.SStrategicCategoryReqVO;
import com.movitech.mobile.cz.base.common.util.CommonConstants;
import com.movitech.mobile.cz.base.util.UserUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.movitech.mobile.cz.base.modules.controller.RestReturnResult;
import com.movitech.mobile.cz.base.bizconfig.entity.SStrategicCategory;
import com.movitech.mobile.cz.base.bizconfig.service.SStrategicCategoryService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
/**
 * <p>
 * SStrategicCategory 前端控制器
 * </p>
 *
 * @author Movitech Mobile
 * @since 2018-02-28
 */
@RestController
@RequestMapping("/v1/sStrategicCategory")
@Api(value = "战略需求分类（战略采购分类）基础操作接口", description = "战略需求分类（战略采购分类）基础操作接口")
public class SStrategicCategoryController {
    @Autowired
    @Qualifier("sStrategicCategoryService")
    private SStrategicCategoryService sStrategicCategoryService;

    @GetMapping("/allList")
    @ApiOperation(
            value = "获取所有战略需求分类（战略采购分类）接口",
            notes = "获取所有战略需求分类（战略采购分类）接口",
            response = SStrategicCategory.class
    )
    public RestReturnResult list() {
        RestReturnResult restReturnResult = RestReturnResult.success();
        Page<SStrategicCategory> page = sStrategicCategoryService.selectPage(new Page<SStrategicCategory>());
        restReturnResult.setData(page);
        return restReturnResult;
    }

    @PostMapping("/searchList/{pageNumber}")
    @ApiOperation(
            value = "战略需求分类（战略采购分类）列表查询接口",
            notes = "战略需求分类（战略采购分类）列表查询接口",
            response = SStrategicCategory.class
    )
    public RestReturnResult searchList(@RequestBody SStrategicCategory sStrategicCategory,
                @ApiParam(value = "分页页数")@PathVariable Integer pageNumber) {
        RestReturnResult restReturnResult = RestReturnResult.success();
        Page<SStrategicCategory> page = new Page<>();
        page.setCurrent(pageNumber);
        EntityWrapper wrapper = new EntityWrapper<>();
        wrapper.setEntity(sStrategicCategory);
        page = sStrategicCategoryService.selectPage(page,wrapper);
        restReturnResult.setData(page);
        return restReturnResult;
    }

    @GetMapping("/getSStrategicCategory/{id}")
    @ApiOperation(
            value = "战略需求分类（战略采购分类）对象ID获取接口",
            notes = "战略需求分类（战略采购分类）对对象ID获取接口",
            response = SStrategicCategory.class
    )
    public RestReturnResult addSStrategicCategory(@PathVariable String id) {
        RestReturnResult restReturnResult = RestReturnResult.success();
        SStrategicCategory sStrategicCategory = sStrategicCategoryService.getSStrategicCategoryById(id);
        restReturnResult.setData(sStrategicCategory);
        return restReturnResult;
    }

    @PostMapping("/insertOrUpdate")
    @ApiOperation(
            value = "专业维护、品类维护",
            notes = "战略需求分类（战略采购分类）添加/更新接口",
            response = SStrategicCategory.class
    )
    public RestReturnResult insertOrUpdate(@RequestBody SStrategicCategory sStrategicCategory) {
        RestReturnResult restReturnResult = RestReturnResult.success();
        restReturnResult.setData(sStrategicCategoryService.insertOrUpdateSStrategicCategory(sStrategicCategory));
        return restReturnResult;
    }

    @GetMapping("/getSpecialityList")
    @ApiOperation(
            value = "战略需求分类（战略采购分类）专业列表",
            notes = "战略需求分类（战略采购分类）专业列表",
            response = SStrategicCategory.class
    )
    public RestReturnResult getSpecialityList() {
        RestReturnResult restReturnResult = RestReturnResult.success();
        restReturnResult.setData(sStrategicCategoryService.getSpecialityList());
        return restReturnResult;
    }

//    @PostMapping("/add")
//    @ApiOperation(
//            value = "战略需求分类（战略采购分类）添加接口",
//            notes = "战略需求分类（战略采购分类）添加接口",
//            response = SStrategicCategory.class
//    )
//    public RestReturnResult add(@RequestBody SStrategicCategory sStrategicCategory) {
//        RestReturnResult restReturnResult = RestReturnResult.success();
//        sStrategicCategoryService.insert(sStrategicCategory);
//        restReturnResult.setData(sStrategicCategory);
//        return restReturnResult;
//    }

//    @PutMapping("/update")
//    @ApiOperation(
//            value = "战略需求分类（战略采购分类）更新接口",
//            notes = "战略需求分类（战略采购分类）更新接口",
//            response = SStrategicCategory.class
//    )
//    public RestReturnResult update(@RequestBody SStrategicCategory sStrategicCategory) {
//        RestReturnResult restReturnResult = RestReturnResult.success();
//        sStrategicCategoryService.updateById(sStrategicCategory);
//        restReturnResult.setData(sStrategicCategory);
//        return restReturnResult;
//    }

    @GetMapping("/delete/{id}")
    @ApiOperation(value = "战略需求专业、品类删除接口", notes = "战略需求分类（战略采购分类）删除接口")
    public RestReturnResult delete(@PathVariable String id) {
        RestReturnResult restReturnResult = RestReturnResult.success();
        sStrategicCategoryService.deleteById(id);
        return restReturnResult;
    }

    @GetMapping("/updateStatus/{id}")
    @ApiOperation(
            value = "战略需求分类（战略采购分类）通过ID启用/停用接口",
            notes = "战略需求分类（战略采购分类）通过ID启用/停用接口",
            response = SStrategicCategory.class
    )
    public RestReturnResult updateStatus(@PathVariable String id) {
        RestReturnResult restReturnResult = RestReturnResult.success();
        sStrategicCategoryService.updateStatus(id);
        return restReturnResult;
    }

    @GetMapping("/getCategoryList/{parentId}")
    @ApiOperation(
            value = "战略需求分类（战略采购分类）品类列表", notes = "战略需求分类（战略采购分类）"
    )
    public RestReturnResult getCategoryList(@PathVariable String parentId) {
        RestReturnResult restReturnResult = RestReturnResult.success();
        
        restReturnResult.setData(sStrategicCategoryService.getCategoryList(parentId));
        
        return restReturnResult;
    }

    @PostMapping("/getPageList")
    @ApiOperation(
            value = "战略需求分类（战略采购分类）列表查询接口",
            notes = "战略需求分类（战略采购分类）列表查询接口",
            response = SStrategicCategory.class
    )
    public RestReturnResult searchList(@RequestBody SStrategicCategoryReqVO sStrategicCategoryReqVO) {
        RestReturnResult restReturnResult = sStrategicCategoryService.getPage(sStrategicCategoryReqVO);
        return restReturnResult;
    }


}

